import request from "@/utils/request";
import {PATH_SYS_DNF} from "@/utils/constant";
import {Shop} from "@/api/sys/dnf/shop/types";

const baseUrl = PATH_SYS_DNF + '/shop/'

/**
 * 查询商店列表 - 带分页
 * @param data
 */
export function getShopListApi(data: PageQuery<Shop>): PromisePageListType<Shop> {
    return request.post(baseUrl + 'list', data)
}

/**
 * 通过商店id获取商店信息
 * @param id
 */
export function getShopByIdApi(id: number): Promise<Shop> {
    return request.get(baseUrl + id)
}

/**
 * 修改商店
 * @param id
 * @param data
 */
export function editShopApi(id: number, data: Shop): Promise<any> {
    return request.patch(baseUrl + id, data)

}

/**
 * 添加商店
 * @param data
 */
export function addShopApi(data: Shop): Promise<any> {
    return request.post(baseUrl, data)
}

/**
 * 删除商店
 * @param id
 */
export function deleteShopApi(id: number): Promise<any> {
    return request.delete(baseUrl + id)
}

/**
 * 购物
 * @param id
 */
export function buyShopApi(id: number): Promise<any> {
    return request.post(baseUrl + 'buy/' + id)
}